package org.oneboot.core.lang.math;

/**
 */
public enum CurrencyEnum {
    /** 人民币 [￥] */
    CNY("CNY", "156", new String(new char[] { 0xffe5 })),

    /** 美元 [US $] */
    USD("USD", "840", new String(new char[] { 0x55, 0x53, 0x20, 0x24 })),

    /** 港元 [HK$] */
    HKD("HKD", "344", new String(new char[] { 0x48, 0x4b, 0x24 })),

    /** 台币 [NT$] */
    TWD("TWD", "901", new String(new char[] { 0x4e, 0x54, 0x24 })),

    /** 欧元 [€] */
    EUR("EUR", "978", new String(new char[] { 0x20ac })),

    /** 英镑 [￡] */
    GBP("GBP", "826", new String(new char[] { 0xffe1 })),

    /** 日元 [￥] */
    JPY("JPY", "392", new String(new char[] { 0xa5 })),

    /** 巴西雷亚尔 [R$] */
    BRL("BRL", "986", new String(new char[] { 0x52, 0x24 })),

    /** 卢布 [руб.] */
    RUB("RUB", "643", new String(new char[] { 0x440, 0x443, 0x431, 0x2e })),

    /** 澳元 [AU $] */
    AUD("AUD", "036", new String(new char[] { 0x41, 0x55, 0x20, 0x24 })),

    /** 加元 [C$]*/
    CAD("CAD", "124", new String(new char[] { 0x43, 0x24 })),

    /** 印度卢比 [Rs.] */
    INR("INR", "356", new String(new char[] { 0x52, 0x73, 0x2e })),

    /** 乌克兰里夫纳 [грн.] */
    UAH("UAH", "980", new String(new char[] { 0x433, 0x440, 0x43d, 0x2e })),

    /** 墨西哥比索 [MXN$] */
    MXN("MXN", "484", new String(new char[] { 0x4d, 0x58, 0x4e, 0x24 })),

    /** 瑞士法郎 [CHF] */
    CHF("CHF", "756", new String(new char[] { 0x43, 0x48, 0x46 })),

    /** 新加坡元 [S$] */
    SGD("SGD", "702", new String(new char[] { 0x53, 0x24 })),

    ;

    /** 币种代码 */
    private final String currencyCode;

    /** 币种值 */
    private final String currencyValue;

    /** 币种符号 */
    private final String currencyLabel;

    /**
     * 私有构造函数。
     *
     * @param currencyCode   币种代码
     * @param currencyValue  币种值
     * @param currencyLabel  币种符号
     */
    private CurrencyEnum(String currencyCode, String currencyValue, String currencyLabel) {
        this.currencyCode = currencyCode;
        this.currencyValue = currencyValue;
        this.currencyLabel = currencyLabel;
    }

    /**
     * Getter method for property <tt>currencyCode</tt>.
     *
     * @return property value of currencyCode
     */
    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * Getter method for property <tt>currencyValue</tt>.
     *
     * @return property value of currencyValue
     */
    public String getCurrencyValue() {
        return currencyValue;
    }

    /**
     * Getter method for property <tt>currencyLabel</tt>.
     *
     * @return property value of currencyLabel
     */
    public String getCurrencyLabel() {
        return currencyLabel;
    }

    /**
     * 通过枚举<code>currencyCode</code>获得枚举。
     *
     * @param currencyCode 币种代码
     * @return 币种枚举
     */
    public static CurrencyEnum getByCurrencyCode(String currencyCode) {
        for (CurrencyEnum each : values()) {
            if (each.getCurrencyCode().equals(currencyCode)) {
                return each;
            }
        }
        return null;
    }

    /**
     * 通过枚举<code>currencyCode</code>获得枚举。
     *
     * @param currencyValue 币种值
     * @return                          币种枚举
     */
    public static CurrencyEnum getByCurrencyValue(String currencyValue) {
        for (CurrencyEnum each : values()) {
            if (each.getCurrencyValue().equals(currencyValue)) {
                return each;
            }
        }
        return null;
    }
}
